package com.soft.javase.day15.reflects;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/5/27
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        List<Integer> list = new ArrayList<>();
        list.add(10);
        list.add(20);
        list.add(30);

        Class<List> listClass = List.class;
        Method addMethod = listClass.getDeclaredMethod("add", Object.class);
        addMethod.invoke(list,"abc");

        System.out.println(list);
    }
}
